<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>测试 - layui</title>
  <link th:href="@{/static/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>

<div class="layui-container">
  <div class="layui-progress" style="margin: 15px 0 30px;">
    <div class="layui-progress-bar" lay-percent="100%"></div>
  </div>
  
  
  <div class="layui-btn-container">
    <button class="layui-btn" test-active="test-form">一个按钮</button>
    <button class="layui-btn layui-btn-normal" id="test2">当前日期</button>
  </div>
  
  <blockquote class="layui-elem-quote" style="margin-top: 30px;">
    <div class="layui-text">
      <ul>
        <li>你当前预览的是：<span>layui-v<span id="version"></span></span></li>
        <li>这是一个极其简洁的演示页面</li>
      </ul>
    </div>
  </blockquote>


  <form id="ddd" class="layui-form" action="">
    <div class="layui-form-item">
      <label class="layui-form-label">单行输入框</label>
      <div class="layui-input-block">
        <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">验证必填项</label>
      <div class="layui-input-block">
        <input type="text" name="username" lay-verify="required" lay-reqtext="用户名是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>

  <div id="hdqkyc" style="width: 100%;height: 260px;"></div>


</div>



<!-- 引入 layui.js 的 <script> 标签最好放置在 html 末尾 -->
<script th:src="@{/static/layui/layui.js}"></script>
<script>
layui.use(function(){
  var layer = layui.layer
  ,form = layui.form
  ,laypage = layui.laypage
  ,element = layui.element
  ,laydate = layui.laydate
  ,util = layui.util;
  
  //欢迎信息
  layer.msg('Hello World');
  
  //输出版本号
  lay('#version').html(layui.v);
  
  //日期
  laydate.render({
    elem: '#test2'
    ,value: new Date()
    ,isInitValue: true
  });
  
  //触发事件
  util.event('test-active', {
    'test-form': function(){
      layer.open({
        type: 1
        ,resize: false
        ,shadeClose: true
        ,content: ['<ul class="layui-form" style="margin: 10px;">'
          ,'<li class="layui-form-item">'
            ,'<label class="layui-form-label">输入框</label>'
            ,'<div class="layui-input-block">'
              ,'<input class="layui-input" name="field1">'
            ,'</div>'
          ,'</li>'
          ,'<li class="layui-form-item">'
            ,'<label class="layui-form-label">选择框</label>'
            ,'<div class="layui-input-block">'
              ,'<select name="field2">'
                ,'<option value="A">A</option>'
                ,'<option value="B">B</option>'
              ,'<select>'
            ,'</div>'
          ,'</li>'
          ,'<li class="layui-form-item" style="text-align:center;">'
            ,'<button type="submit" lay-submit lay-filter="*" class="layui-btn">提交</button>'
          ,'</li>'
        ,'</ul>'].join('')
        ,success: function(layero){
          layero.find('.layui-layer-content').css('overflow', 'visible');
          
          form.render().on('submit(*)', function(data){
            layer.msg(JSON.stringify(data.field));
          });
        }
      });
    }
  });
});
</script>
<script th:src="@{/static/layui/layui.js}"></script>
<script th:src="@{/static/layui/echarts.min.js}"></script>
<script th:src="@{/static/layui/echartsTheme.js}"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
  layui.use(['form'], function(){
    var $ = layui.$
    var form = layui.form
            ,layer = layui.layer
    // 渲染活动情况预测
    var myCharts = echarts.init(document.getElementById('hdqkyc'), myEchartsTheme);
    var base = +new Date(1968, 9, 3);
    var oneDay = 24 * 3600 * 1000;
    var date = [];

    var data = [Math.random() * 300];

    for (var i = 1; i < 20000; i++) {
      var now = new Date(base += oneDay);
      date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
      data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
    }

    option = {
      tooltip: {
        trigger: 'axis',
        position: function (pt) {
          return [pt[0], '10%'];
        }
      },
      title: {
        left: 'center',
        text: '大数据量面积图',
      },
      toolbox: {
        feature: {
          dataZoom: {
            yAxisIndex: 'none'
          },
          restore: {},
          saveAsImage: {}
        }
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: date
      },
      yAxis: {
        type: 'value',
        boundaryGap: [0, '100%']
      },
      dataZoom: [{
        type: 'inside',
        start: 0,
        end: 10
      }, {
        start: 0,
        end: 10
      }],
      series: [
        {
          name: '模拟数据',
          type: 'line',
          symbol: 'none',
          sampling: 'lttb',
          itemStyle: {
            color: 'rgb(255, 70, 131)'
          },
          areaStyle: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
              offset: 0,
              color: 'rgb(255, 158, 68)'
            }, {
              offset: 1,
              color: 'rgb(255, 70, 131)'
            }])
          },
          data: data
        }
      ]
    };
    myCharts.setOption(option);


    //监听提交
    form.on('submit(demo1)', function(data){
      $.ajax({
        contentType: "application/json;charset=UTF-8",
        type: "POST",
        data: JSON.stringify(data.field),
        url: "/ddd",
        success: function (data) {
          if (data=="11"){
            layer.alert("操作成功",function(){
              layer.closeAll();
            });
          }else {
            layer.alert(data);
          }
        },
        error: function (data) {
          layer.alert("操作请求错误，请您稍后再试");
        }
      });





      return false;
    });

  });
</script>
</body>
</html>
